<% can_edit = manages_org? %>
<%= section_panel 'Environment Profiles',
                  :width => 'single',
                  :menu  => can_edit &&
                      [link_to(icon('plus', 'Add'),
                               new_organization_environment_path,
                               :remote => true,
                               :class  => 'btn btn-mini')] do %>
  <%= ci_list(@environments, :new_link => can_edit && link_to('New Environment Profile...',
                                                               new_organization_environment_path,
                                                               :remote => true)) do |builder, target| %>
    <% builder.target link_to('', edit_organization_environment_path(target), :remote => true) %>
    <% builder.icon :none %>
    <% builder.top do %>
      <span class="topname"><%= target.ciName %></span>
      <span class="topdesc">
  			<%= target.ciAttributes.description %>
  		</span>
    <% end %>
    <% builder.middle do %>
      <% if target.clouds.present? %>
        <%= 'cloud'.pluralize(target.clouds.size) %>
        <strong><%= target.clouds.sort_by { |c| c.relationAttributes.priority }.map(&:toCi).map(&:ciName).join(', ') %></strong>
      <% end %>
    <% end %>
    <% builder.status do %>
      <% availability = target.ciAttributes.availability %>
      <div class="marker" title="<%= availability %> availability">
        <%= icon(availability == 'redundant' ? 'cubes' : 'cube', '', 'fa-lg fa-fw') %>
      </div>
    <% end %>
    <% builder.menu do |ci| %>
      <%= link_to(icon('edit', ' Edit'), edit_organization_environment_path(ci), :remote => true) %>
      <%= link_to(icon('trash', ' Delete'), organization_environment_path(ci), :method => :delete, :remote => true, :confirm => 'Confirm delete?') if can_edit %>
    <% end %>
  <% end %>
<% end %>
<div id="environment_details"></div>
